<?php
namespace Admin\Controller;
use Think\Controller;
class EnrollController extends Controller {

    //显示用户列表方法
    public function EnrolllistJson(){
       
       $use= $this->users=M('Enroll')->select();
   echo json_encode($use);
      } 
  
    public function EnrollList() {
        $EnrollModel = M('enroll');
        $EnrollList = $EnrollModel -> select();

        $this -> assign('enrollList',$EnrollList);
        $this -> display();
    }
   public function doAddEnroll() {
        $EnrollModel = M('enroll');

        $addEnrollData['id'] = NULL;
       
        $addEnrollData['number'] = I('post.number');
        $addEnrollData['time'] = date('y-m-d H:m:s');


        $res = $EnrollModel -> add($addEnrollData);

        if ($res) {
            $this -> success("添加成功!");
        } else {
            $this -> error("添加失败!");
        }
    }
       public function updateenroll($id){
        $enrollModel = M('enroll');
        $enrollData['id'] = $id;
        $res = $enrollModel -> where($enrollData) -> find();
        $this -> assign('enrollInfo', $res);
        $this -> display();
    }
    public function doupdateEnroll() {
        $EnrollModel = M('enroll');

        $updateEnrollData['id'] = I('post.id');
        $updateEnrollData['number'] = I('post.number');
        $updateEnrollData['datetime'] = date('y-m-d H:m:s');

        $res = $EnrollModel -> save($updateEnrollData);

        if ($res) {
            $this -> success("修改成功!",U('enroll/enrollList'));
        } else {
            $this -> error("修改失败!");
        }
    }
       public function delEnroll($id){
        $res= M("enroll") -> where("id = '$id'") -> delete();
       if ($res) {
            $this -> success("删除成功!",U('enroll/enrollList'));
        } else {
            $this -> error("修改失败!");
        }
    }

    

    //  public function index(){
    //     $share = M('share');
    //     //用户名条件搜索
    //     if(!empty($_GET['name'])){
    //       $where['name'] = array('like','%'.$_GET['name'].'%');
    //     }
    //     $total=$user->where($where)->count();
        
    //     //实例化分页类
    //     $page=new \Think\Page($total,5);
    //     $this->assign('show',$page->show());
    //     $data=$user->where($where)->page(I('get.p',1),5)->select();
    //     $this->assign('data',$data);
    //     $this->display();
    // }
}
